package schema

import (
	"entgo.io/ent"
	"entgo.io/ent/schema/edge"
	"entgo.io/ent/schema/field"
)

// ReportVulnerability holds the schema definition for the ReportVulnerability entity.
type ReportVulnerability struct {
	ent.Schema
}

// Fields of the ReportVulnerability.
func (ReportVulnerability) Fields() []ent.Field {
	return []ent.Field{
		field.String("vulnerability_id").NotEmpty(),
		field.String("title").NotEmpty(),
		field.String("description").Optional(),
		field.Strings("aliases").Optional(),
		field.String("severity").Optional(),
		field.String("severity_type").Optional(),
		field.Float("cvss_score").Optional(),
		field.JSON("severity_details", map[string]interface{}{}).Optional(),
		field.Time("created_at").Optional(),
		field.Time("updated_at").Optional(),
	}
}

// Edges of the ReportVulnerability.
func (ReportVulnerability) Edges() []ent.Edge {
	return []ent.Edge{
		edge.From("package", ReportPackage.Type).
			Ref("vulnerabilities").
			Unique(),
	}
}
